#include <iostream>
#include "network/buffer.hpp"

using namespace ibox::network;

int main() {
    Buffer buf;
    std::cout << "readable size: " << buf.readable_size() << '\n';
    // 先插入4个字节
    buf.append("abcd", 4);
    std::cout << "readable size: " << buf.readable_size() << '\n';
    // 再插入4个字节
    buf.append("efgh", 4);
    std::cout << "readable size: " << buf.readable_size() << '\n';
    // 将所有的数据读出来
    char buf2[10] = { 0 };
    auto len = buf.fetch(buf2, 10);
    std::cout << "读取到buf2, 读取了" << len << "字节的数据\n";

    std::cout << "readable size: " << buf.readable_size() << '\n';
    std::cout << "buf2: " << buf2 << '\n';
}
